package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.User;



@Repository()
public interface User_Mapper extends BaseMapper<User>{
	
	@Select("select user.*,department.name department_name "
			+ " from user inner join department on user.department_id=department.id ${where} ${limitstr}")
	public List<User> select(SearchInfo info);
	@Select("select count(1) from user inner join department on user.department_id=department.id   ${where} ")
	public long selectCount(SearchInfo info);
	
	@Insert("insert into user (name,pass,sex,department_id,createdate) values(#{name},#{pass},#{sex},#{department_id},#{createdate})")
	public void insert (User u);
	
	@Update("update user set name=#{name},sex=#{sex},department_id=#{department_id} where id=#{id}")
	public void update (User u);
	
	
	@Select("delete from user where id=#{id}")
	public void delete(int id);
	
	@Select("select * from user where id=#{id} ")
	public User selectById(int id);
	
	@Select("select * from user where name=#{name} ")
	public User login(User u);
	
}
